package com.bds.btcdc.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Utils {
	// 返回第一个匹配记录,()功能
	public static String regex(String regex, String str) {
		Matcher matcher = Pattern.compile(regex).matcher(str);
		if (matcher.find()) {
			return matcher.group(1);
		}
		return "";
	}

	// 返回所有匹配的记录
	public static String regexAll(String regex, String str) {
		Matcher matcher = Pattern.compile(regex).matcher(str);
		String match_all = "";
		while (matcher.find()) {
			match_all += matcher.group();
		}
		return match_all;
	}

}
